<template>
	<view class="content">
		<u-navbar>
			<view class="" slot="center">
				订单详情
			</view>
		</u-navbar>
		<view class="order_details_1" :style="{'height':clientHeight+'px','margin-top':navHeight+'px'}">
			<view class="order_details_7">
				<text decode="true" class="status">已支付</text>
				<text decode="true" class="smallTitle">支付成功,祝您用餐愉快</text>
			</view>
			<view class="order_details_2">
				<view class="goods">
					<view v-for="(item_goods, index) in list_goods" :key="index" class="row">
						<image v-on:click="pic_9_click(item_goods)"  :src="item_goods.pic" mode="scaleToFill" border="0"    class="pic"></image>
						<view class="order_details_10">
							<text decode="true" class="good">{{item_goods.good}}</text>
							<text decode="true" class="num">{{item_goods.num}}</text>
						</view>
						<text decode="true" class="money">{{item_goods.money}}</text>
					</view>
				</view>
				<view class="order_details_15">
					<text decode="true" class="order_details_16">共2份小计￥57.60</text>
				</view>
			</view>
			<image v-on:click="banner_3_click()"  src="../../static/images/order-details/order_details_banner_3.jpg" mode="scaleToFill" border="0"    class="banner"></image>
			<button v-on:click="btAdd_4_click()" class="btAdd">查看更多
			</button>
		</view>
		

		<view class="loading">{{loadingText}}</view>
		<view class="ymBbottom"></view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			clientHeight:0,
			navHeight:0,
			loadingText: '',
			list_goods: [
			{
				good:'杯鸭碟头饭',
				num:'数量:1',
				pic:'../../static/images/order-details/order_details_pic_9.jpg',
				money:'￥2880',
			
			},
			{
				good:'杯鸭碟头饭',
				num:'数量:1',
				pic:'../../static/images/order-details/order_details_pic_9.jpg',
				money:'￥2880',
			
			},
			{
				good:'杯鸭碟头饭',
				num:'数量:1',
				pic:'../../static/images/order-details/order_details_pic_9.jpg',
				money:'￥2880',
			
			},
			],
			order_details_16:'共2份小计￥57.60',
			
		

			page:0,//当前分页页码
			apiUrl:'',//后端接口地址
			id:'',//传值使用,方便存在本地的locakStorage  
			del_id:''//方便存在本地的locakStorage  
		}
	},
	components:{

	},
	onLoad(options) {
		this.getClineHeight()
		this.navHeight = this.getBarHeight()
		//检查是否登录参考代码,需要用的时候，可以把注释取掉
		//if(this.checkLogin()==false){
		//	return;
		//}
		
		//this.getLaction();//得到gps

		this.page=0;

		//检测有没有传入id参数
		if (options.id != null && options.id !=""){
			this.id=options.id;
		}   
		//执行初始化,需要用的时候，可以把注释取掉
		//this.Refresh("init");

	},
	onShow() {
		console.log("on show");
		//if(this.checkLogin()==false){
		//	return;
		//}

		//执行初始化,需要用的时候，可以把注释取掉
		//this.Refresh("init");
	},
	onPullDownRefresh: function() {
		//下拉刷新的时候请求一次数据
		this.Refresh();
	},
	methods: {
		getBarHeight(){
			const res = uni.getSystemInfoSync()
			if(res.platform==='ios'){
				return 44+res.statusBarHeight
			}else if(res.platform==='android'){
				return 48+res.statusBarHeight
			}else{
				return 0;
			}
		},
		getNavBarHeight(){
			const res = uni.getSystemInfoSync()
			if(res.platform==='ios'){
				return 44
			}else if(res.platform==='android'){
				return 48
			}else{
				return 0;
			}
		},
		//获取可视区域高度
		getClineHeight(){
			const res = uni.getSystemInfo({
				success:(res=>{
					// #ifdef H5
					this.clientHeight = res.windowHeight-this.getBarHeight();
					// #endif
					// #ifdef APP-PLUS
					this.clientHeight = res.windowHeight -uni.upx2px(80)-this.getBarHeight();
					// #endif
				})
			});
			
		},
		/**
		* banner_3处理函数
		* 数据绑定  data-index="{{index}}" 
		* 数据取值  var index = e.currentTarget.dataset.index; var cata = this.list_cata_list[index];
		*/
		banner_3_click:function(event){
		
		},
		
		/**
		* btAdd_4处理函数
		* 数据绑定  data-index="{{index}}" 
		* 数据取值  var index = e.currentTarget.dataset.index; var cata = this.list_cata_list[index];
		*/
		btAdd_4_click:function(event){
			this.$tab.reLaunch("/pages/index")
					// this.Refresh("btAdd_click");
		},
		
		/**
		* pic_9处理函数
		* 数据绑定  data-index="{{index}}" 
		* 数据取值  var index = e.currentTarget.dataset.index; var cata = this.list_cata_list[index];
		*/
		pic_9_click:function(event){
		
		},
		
		

		//刷新数据
		Refresh:function(_action) {
		
			uni.showLoading();
			
			//提交到服务器
			var that = this
			var url=that.apiUrl+'{server_code_file_path}';
			console.log(url);
			uni.request({
			url: url,//后端接口地址，需要改成自己的接口地址
			data: {
				action: _action,//上传动作，如按钮点击会产生click动作，分页也会产生，在后端根据具体的动作来判断事件
				uid: that.getUid(),//上传用户id,在登录中获得
				//上传页面中的变量
				//定义变量---start
				
				//定义变量---end
				id: that.id,//上传id值，后端可以根据此值来操作当前id
				del_id: that.del_id,//在列表中删除按钮选中时，上传到有后端，进行删除操作
				page:that.page
			},
			method: 'GET',
			success: function (res) {//后端返回数据

				// 隐藏导航栏加载框  
				uni.hideNavigationBarLoading();
				// 停止下拉动作  
				uni.stopPullDownRefresh();  

				// 隐藏加载框  
				uni.hideLoading();  

				var tmp = res.data;

				//初始化，对页面上的控件进行赋值操作
				if(_action=="init"){

				}

{deal_listpages}

				that.pic=tmp.pic;
				that.good=tmp.good;
				that.num=tmp.num;
				that.money=tmp.money;
				that.order_details_16=tmp.order_details_16;
				


				//如果后端有返回消息，则弹出消息提示
				if (tmp.message != null && tmp.message != "") {
					uni.showToast({
					title: tmp.message,
					icon: 'none',
					duration: 2000
					})
				}

	//可以以下面处理返回处理代码
	if (_action =="btAdd_click"){
	   //if(tmp.status=="1"){
	   
	   //}
	}


				//如果后端有返回页码，则更改当前页码
				if(tmp.page!=null && tmp.page!=""){
					page=tmp.page;
				}					

			},
			fail: function (res) {
				uni.showToast({
					title: "服务器访问失败",
					icon: 'none',
					duration: 2000
				})
				console.log(res.data);
				console.log('is failed')
			}
			})
		},
	}
}
</script>

<style lang="scss" scoped>
   @import './order-details.scss'
</style>